package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.query.CollectQueryObject;
import cn.wolfcode.trip.base.service.ICollectService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/collections")
public class CollectController {

    @Autowired
    private ICollectService collectService;

    /**
     * 返回搜素封面和内容资源的接口
     * 1.资源 /collections
     * 2.请求方式 get
     * 3.请求参数 type keyword
     * 4.返回结果 json
     */
    @GetMapping
    public PageInfo collect(CollectQueryObject qo){
        Integer type = qo.getType();
            if (type == 1){//攻略
                return collectService.collectStrategyDetail(qo);
            } else if (type == 2){//游记
                return collectService.collectTravel(qo);
            } else  if (type == 3){//日报
                return collectService.collectNews(qo);
            }
        return null;
    }
}
